package org.finesys.system.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.finesys.common.mp.core.service.impl.BaseServiceImpl;
import org.finesys.system.api.entity.SysPost;
import org.finesys.system.api.entity.SysUserPost;
import org.finesys.system.mapper.SysUserPostMapper;
import org.finesys.system.service.SysUserPostService;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
public class SysUserPostServiceImpl extends BaseServiceImpl<SysUserPostMapper, SysUserPost> implements SysUserPostService {

    /**
     * 根据 userId 删除对应的用户岗位信息
     */
    @Override
    public void deleteUserPostByUserId(Long userId) {
        baseMapper.delete(Wrappers.<SysUserPost>update().lambda().eq(SysUserPost::getUserId, userId));
    }

    @Override
    public void deleteUserPostByUserIds(Long[] userIds) {
        baseMapper.delete(Wrappers.<SysUserPost>update().lambda().in(SysUserPost::getUserId, Arrays.asList(userIds)));
    }

    @Override
    public List<SysPost> findPostsByUserId(Long userId) {
        return baseMapper.findPostsByUserId(userId);
    }
}
